package vistas;

import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JInternalFrame;
import javax.swing.JTextField;
import java.awt.Rectangle;
import java.rmi.RemoteException;

import javax.swing.JLabel;
import javax.swing.JButton;

import controlador.Controlador;
import java.awt.Dimension;

public class AgregarMozo extends JInternalFrame {

	private Controlador controlador;
	private JPanel jContentPane = null;
	private JTextField nombre = null;
	private JTextField apellido = null;
	private JLabel nombrelbl = null;
	private JLabel apellidolbl = null;
	private JButton agregarMozo = null;
	private JButton salir = null;
	/**
	 * This is the xxx default constructor
	 */
	public AgregarMozo() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(309, 200);
		this.setTitle("Agregar un Mozo");
		this.setContentPane(getJContentPane());
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			apellidolbl = new JLabel();
			apellidolbl.setBounds(new Rectangle(60, 70, 70, 20));
			apellidolbl.setText("Apellido:");
			nombrelbl = new JLabel();
			nombrelbl.setBounds(new Rectangle(60, 20, 70, 20));
			nombrelbl.setText("Nombre:");
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(getNombre(), null);
			jContentPane.add(getApellido(), null);
			jContentPane.add(nombrelbl, null);
			jContentPane.add(apellidolbl, null);
			jContentPane.add(getAgregarMozo(), null);
			jContentPane.add(getSalir(), null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes nombre	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getNombre() {
		if (nombre == null) {
			nombre = new JTextField();
			nombre.setBounds(new Rectangle(150, 25, 100, 20));
		}
		return nombre;
	}

	/**
	 * This method initializes apellido	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getApellido() {
		if (apellido == null) {
			apellido = new JTextField();
			apellido.setBounds(new Rectangle(150, 70, 100, 20));
		}
		return apellido;
	}

	/**
	 * This method initializes agregarMozo	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getAgregarMozo() {
		if (agregarMozo == null) {
			agregarMozo = new JButton();
			agregarMozo.setBounds(new Rectangle(25, 110, 110, 35));
			agregarMozo.setText("Agregar");
			agregarMozo.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					String nom = getNombre().toString();
					String ape = getApellido().toString();
					try {
						controlador.agregarMozo(nom,ape);
					} catch (RemoteException e1) {
						// TODO Auto-generated catch block
						e1.printStackTrace();
					}}
			});
		}
		return agregarMozo;
	}

	/**
	 * This method initializes salir	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getSalir() {
		if (salir == null) {
			salir = new JButton();
			salir.setBounds(new Rectangle(165, 110, 110, 35));
			salir.setText("Cancelar");
			salir.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					dispose();
				}
			});
		}
		return salir;
	}
	
	public void setControlador(Controlador controlador) {
		this.controlador = controlador;
	}

}  //  @jve:decl-index=0:visual-constraint="10,10"
